home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Utilities ƒ / MPW Tools ƒ / Simula4.07 / Simula 4.07ƒ / SInterfaces / macControlMgr.sim < prev    next >
Encoding:
Text File  |  1989-05-01  |  3.8 KB  |  142 lines  |  [TEXT/MPS ]

  1. % ---------------------------------------------------------------------------
  2. %    Class MACControlMrg
  3. %
  4. % In this module you find the programmers interface to Controls.
  5. % It is built on top of the TOOLBOX routines in TOOLBOXControls.
  6. % For a description of the routines see Inside Macintosh, chapter 10.
  7. %
  8. %
  9. % 890317/Boris Magnusson
  10. % 890408/Göran Eriksson
  11. %
  12. % ---------------------------------------------------------------------------
  13. %    Datastructures used in Control Manager
  14. %
  15. %    ControlPtr = ^ControlRecord;
  16. %
  17. %    ControlRecord = PACKED RECORD
  18. %                    nextControl: ControlHandle;
  19. %                    contrlOwner: WindowPtr;
  20. %                    contrlRect: Rect;
  21. %                    contrlVis: Byte;
  22. %                    contrlHilite: Byte;
  23. %                    contrlValue: INTEGER;
  24. %                    contrlMin: INTEGER;
  25. %                    contrlMax: INTEGER;
  26. %                    contrlDefProc: Handle;
  27. %                    contrlData: Handle;
  28. %                    contrlAction: ProcPtr;
  29. %                    contrlrfCon: LONGINT;
  30. %                    contrlTitle: Str255;
  31. %                    END; {ControlRecord}
  32. external text procedure Text_String="::SInterfaces:Text_String";
  33. external class MacControl="::SInterfaces:MacControl";
  34. external class MacRect="::SInterfaces:MacRect";
  35. external class MacPoint="::SInterfaces:MacPoint";
  36. external class MacWindow="::SInterfaces:MacWindow";
  37. External class ToolboxControl ="::SInterfaces:ToolboxControl";
  38. Simset class MACControlMgr;
  39. begin
  40.     ref(ToolboxControl) TB;
  41.  
  42. %    PROCEDURE DisposeControl(theControl: ControlHandle);
  43.     PROCEDURE DisposeControl(theControl);
  44.         ref(MacControl) theControl;
  45.     begin
  46.         TB.ToolboxDisposeControl(theControl.Controlptr);
  47.         ConvertToNotice(theControl).Out;
  48.     end;
  49.  
  50. %    PROCEDURE KillControls(theWindow: WindowPtr);
  51.     PROCEDURE KillControls(theWindow);
  52.         ref(MacWindow) theWindow;
  53.     begin
  54.         TB.ToolboxKillControls(theWindow.WindowPtr);
  55.         KillControlsInWindow(theWindow);
  56.     end;
  57.  
  58.     procedure RegisterControl(C, W); ref(MacControl) C; ref(MacWindow) W;
  59.         new ControlNotice(C, W);
  60.  
  61.             
  62. %    FUNCTION FindControl(thePoint: Point; theWindow: WindowPtr;
  63. %                     VAR theControl: ControlHandle): INTEGER;
  64.     short integer procedure FindControl(thePoint, theWindow, theControl);
  65.             name theControl;
  66.             ref(MacPoint) thePoint;
  67.             ref(MacWindow) theWindow;
  68.             ref(MacControl) theControl;
  69.         begin
  70.             integer C;
  71.             FindControl:=TB.ToolboxFindControl(thePoint.h,thePoint.v, 
  72.                         theWindow.WindowPtr, C);
  73.             theControl:-ConvertToControl(C);
  74.         end;
  75.  
  76. %    PROCEDURE DrawControls(theWindow: WindowPtr);
  77.     PROCEDURE DrawControls(theWindow);
  78.         ref(MacWindow) theWindow;
  79.         TB.ToolboxDrawControls(theWindow.WindowPtr);
  80.  
  81.         
  82. %    {new 128K ROM}
  83.  
  84. %    PROCEDURE UpdtControl(theWindow: WindowPtr; updateRgn: RgnHandle);
  85. %    external TB.Toolbox procedure x="$A953" is
  86. %    PROCEDURE UpdtControl(theWindow, updateRgn);
  87. %        integer theWindow;
  88. %        integer updateRgn;;
  89.  
  90. %    PROCEDURE Draw1Control(theControl: ControlHandle);
  91. %    external TB.Toolbox procedure x="$A96D" is
  92. %    PROCEDURE Draw1Control(theControl);
  93. %            integer theControl;
  94.  
  95. % ----------------------------------------------
  96. %    internal routines
  97.     
  98. ref(MACControl) procedure ConvertToControl(ControlPtr); 
  99.     integer ControlPtr; 
  100. begin
  101.     ref(ControlNotice) Temp;
  102.     Temp:-ControlQue.first;
  103.     while temp=/= none and then Temp.C.ControlPtr<>ControlPtr do
  104.         temp:-temp.suc;
  105.     if temp=/= none then
  106.         ConvertToControl:-temp.C;
  107. end;
  108.  
  109. ref(ControlNotice) procedure ConvertToNotice(C); ref(MacControl) C;
  110. begin
  111.     ref(ControlNotice) Temp;
  112.     Temp:-ControlQue.first;
  113.     while temp=/= none and then Temp.C=/=C do
  114.         temp:-temp.suc;
  115.     ConvertToNotice:-temp;
  116. end;
  117.  
  118. procedure KillControlsInWindow(W); ref(MacWindow) W;
  119. begin
  120.     ref(ControlNotice) Temp,TempOut;
  121.     Temp:-ControlQue.first;
  122.     while temp =/= none do
  123.     begin
  124.         if temp.W==W then
  125.         begin
  126.             tempOut:-temp;
  127.             temp:-temp.suc;
  128.             tempOut.out;
  129.         end
  130.         else
  131.             temp:-temp.suc;
  132.     end;
  133.  
  134. end;
  135.  
  136. link class ControlNotice(C,W); ref(MACControl) C; ref(MacWindow) W;
  137.     into(ControlQue);
  138. % ----------------------------------------------
  139.     ref(Head) ControlQue;
  140.     TB:-new ToolboxControl;
  141.     ControlQue:-new Head;
  142. end;